<div class="header-top">
    <div class="center">
        <div class="top">
            <div class="header-left">欢迎您访问{{$setting['vals']['title']}}官方网站</div>
            <div class="header-right">
                @if($member == null)
                <span><a href="javascript:;" onclick="login()"><i class="layui-icon layui-icon-username"></i> 登陆</a></span>
                <span style="margin-left: 10px"><a href="javascript:;" onclick="zhce()">注册</a></span>
                @else
                    <span style="padding-right:10px;"><i class="layui-icon layui-icon-username"></i>{{substr_replace($member->phone,'****',3,4)}}</span>
                    <span style="padding-left: 10px;padding-right:10px;border-left: 1px solid #0000cc;"><a href="/per/index">个人中心</a></span>
                    <span style="padding-left: 10px;border-left: 1px solid #0000cc;"><a href="javascript:;" onclick="logout()"><i class="layui-icon layui-icon-logout"></i>退出</a></span>
                @endif
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<div class="header-log">
    <div class="center">
        <div class="log">
            <a href=""><img src="{{ $logo['vals'] }}" alt="{{$setting['vals']['title']}}"></a>
        </div>
        <form class="search layui-form">

            <div class="search-input">
                <input type="text" name="dw" class="layui-input">
            </div>
            <div class="search-btu">
                <button type="button" class="layui-btn layui-btn-danger" onclick="sc()"><i class="layui-icon layui-icon-search"></i>搜索</button>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form','layer'],function(){
        layer = layui.layer;
        form = layui.form;
        $ = layui.jquery;
    });
    // 搜索文章
    function sc(){

        var wd = $.trim($('input[name="dw"]').val());
        window.location.href='/search?wd='+wd;

        // $.get('/search?wd',$('form').serialize(),function(res){
        //     if(res.code>0){
        //         return setTimeout(function(){},1000);
        //     }
        //
        //
        // },'json');
    }
    function zhce() {
        layer.open({
            type: 2,
            title: '用户注册',
            shadeClose: true,
            shade: 0.8,
            area: ['500px', '400px'],
            // content: '/home/regis' //iframe的url
            content: '/home/login/phoneregister' //iframe的url
        });
        return;
    }
    function login() {
        layer.open({
            type: 2,
            title: '用户登录',
            shadeClose: true,
            shade: 0.8,
            area: ['500px', '400px'],
            content: '/home/login' //iframe的url
        });
    }
    // 退出登录
    function logout(){
        layer.confirm('确定要退出吗？', {
            icon:3,
            btn: ['退出','取消']
        }, function(){
            $.get('/home/login/logout',{},function(res){
                if(res.code>0){
                    return layer.alert(res.msg,{icon:2});
                }
                layer.msg(res.msg);
                setTimeout(function(){window.location.href="/";},1000);
            },'json');
        });
    }

</script>
<div class="nav">
    <div class="center">
        <ul>
            <li><a href="/">首页</a></li>
            @foreach($cates as $item)
                <li><a href="/lists/{{ $item['id'] }}">{{ $item['title'] }}</a></li>
            @endforeach
        </ul>
    </div>
</div>
